package com.ctcemti.mdm.project.sys.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.ctcemti.mdm.project.sys.entity.formdata.BaseReq;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;

/**
 * 操作日志对象 t_sys_operation_log
 * 
 * @author 
 * @date Tue Nov 12 10:28:50 CST 2019
 */
@Data
@ApiModel("操作日志对象")
@JsonIgnoreProperties(value={"handler"})//是json序列化时忽略bean中的一些属性序列化和反序列化时抛出的异常.
public class OperationLog extends BaseReq implements Comparable<OperationLog>
{
    private static final long serialVersionUID = 1L;


    /**
    * 模块id
    */
    @ApiModelProperty(value = "模块id")
    private String moduleId;
    /**
    * 方法名称
    */
    @ApiModelProperty(value = "方法名称")
    @Excel(name="方法名称")
    private String functionName;
    /**
    * 操作内容
    */
    @ApiModelProperty(value = "操作内容")
    @Excel(name="操作内容")
    private String operationContent;
    /**
    * 存储登录人ID,显示名称
    */
    @ApiModelProperty(value = "存储登录人ID,显示名称")
    @Excel(name="操作人")
    private String operator;
    /**
    * 操作时间
    */
    @ApiModelProperty(value = "操作时间")
    @Excel(name="操作时间",databaseFormat="yyyy-MM-dd HH:mm:ss")
    private Date operateTime;
    /**
    * id主键
    */
    @Id
    @ApiModelProperty(value = "id主键")
    private Long id;


    @Transient
    @ApiModelProperty(hidden = true)//swagger忽略属性
    private int rowNum;

    @Transient
    @ApiModelProperty(hidden = true)//swagger忽略属性
    private String errorMsg;

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("moduleId", getModuleId())
            .append("functionName", getFunctionName())
            .append("operationContent", getOperationContent())
            .append("operator", getOperator())
            .append("operateTime", getOperateTime())
            .append("id", getId())
            .toString();
    }

    @Override
    public int compareTo(OperationLog operationLog) {           //重写Comparable接口的compareTo方法，
         return this.rowNum - operationLog.getRowNum();// 根据行号升序排列，降序修改相减顺序即可
    }

}
